home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK2.toast / Development Kits (Disc 2) / QuickTime / Sample Code / QT Codec Acceleration / Samples / ExampleCodec / ExampleCodecTest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-26  |  2.6 KB  |  124 lines  |  [TEXT/CWIE]

  1. #include <Fonts.h>
  2. #include <Movies.h>
  3.  
  4. pascal Boolean filter(MovieController mc, short action, void *params, long refCon);
  5. void main(void)
  6. {
  7.     OSErr err;
  8.     StandardFileReply reply;
  9.     SFTypeList types;
  10.     Movie m;
  11.     short resFref;
  12.     WindowPtr w;
  13.     Rect bounds;
  14.     Boolean done = false;
  15.     ComponentInstance mc;
  16.     Rect maxBounds = {100, 100, 700, 700};
  17.     MCActionFilterWithRefConUPP actionproc;
  18.  
  19.     InitGraf(&qd.thePort);
  20.     InitFonts();
  21.     InitWindows();
  22.     InitMenus();
  23.     TEInit();
  24.     InitDialogs(0L);
  25.     InitCursor();
  26.     MaxApplZone();
  27.  
  28.     actionproc = NewMCActionFilterWithRefConProc(filter);
  29.  
  30.     {
  31.         extern void InstallExampleCodec(void);
  32.         InstallExampleCodec();
  33.     }
  34.  
  35.     EnterMovies();
  36.  
  37.     types[0] = MovieFileType;
  38.     StandardGetFilePreview(nil, 1, types, &reply);
  39.     if (!reply.sfGood) return;
  40.  
  41.     SetRect(&bounds, 75, 75, 75+160,75+120);
  42.     w = NewCWindow(nil, &bounds, reply.sfFile.name, false, 0, (WindowPtr)-1,
  43.         true, 0);
  44.     if (!w) return;
  45.  
  46.     SetPort(w);
  47.  
  48.     err = OpenMovieFile(&reply.sfFile, &resFref, fsRdPerm);
  49.     if (err) return;
  50.  
  51.     err = NewMovieFromFile(&m, resFref, nil, (StringPtr)nil,
  52.                 newMovieActive, nil);
  53.     if (err) return;
  54.  
  55.     CloseMovieFile(resFref);
  56.  
  57.     GetMovieBox(m, &bounds);
  58.     OffsetRect(&bounds, -bounds.left, -bounds.top);
  59.     SetMovieBox(m, &bounds);
  60.  
  61.     mc = NewMovieController(m, &bounds, mcTopLeftMovie);
  62.     MCGetControllerBoundsRect(mc, &bounds);
  63.     MCDoAction(mc, mcActionSetKeysEnabled, (void *)1);
  64.     MCSetActionFilterWithRefCon(mc, actionproc, (long)w);
  65.     
  66.     MCDoAction(mc, mcActionSetGrowBoxBounds, &maxBounds);
  67.     SizeWindow(w, bounds.right, bounds.bottom, false);
  68.  
  69.     ShowWindow(w);
  70.  
  71.     while (done == false) {
  72.         EventRecord theEvent;
  73.  
  74.         GetNextEvent(everyEvent, &theEvent);
  75.         if (MCIsPlayerEvent(mc, &theEvent))
  76.             continue;
  77.  
  78.         switch (theEvent.what) {
  79.             case mouseDown:
  80.                 {
  81.                 WindowPtr whichWindow;
  82.                 short part;
  83.  
  84.                 part = FindWindow(theEvent.where, &whichWindow);
  85.                 switch (part) {
  86.                     case inGoAway:    done = TrackGoAway(whichWindow, theEvent.where);
  87.                                     break;
  88.  
  89.                     case inDrag:    DragAlignedWindow(whichWindow, theEvent.where,
  90.                                         &qd.screenBits.bounds, nil, nil);
  91.                                     break;
  92.                 }
  93.                 }
  94.                 break;
  95.  
  96.             case keyDown:
  97.                 break;
  98.  
  99.  
  100.             case updateEvt:
  101.                 BeginUpdate((WindowPtr)theEvent.message);
  102.                     UpdateMovie(m);
  103.                 EndUpdate((WindowPtr)theEvent.message);
  104.                 break;
  105.  
  106.         }
  107.     }
  108.     DisposeMovieController(mc);
  109.     DisposeMovie(m);
  110. }
  111.  
  112. pascal Boolean filter(MovieController mc, short action, void *params, long refCon)
  113. {
  114. #pragma unused(params)
  115.     if (action == mcActionControllerSizeChanged) {
  116.         Rect bounds;
  117.  
  118.         MCGetControllerBoundsRect(mc, &bounds);
  119.         SizeWindow((void *)refCon, bounds.right, bounds.bottom, false);
  120.     }
  121.  
  122.     return false;
  123. }
  124.